#ifndef CLASS_ENGINE_H
#define CLASS_ENGINE_H

/***
 * class-engine.h
 *
 * Header file for the engine code
 *
 * @author Leigh Ashton <gravious@gmail.com>
 * @since  14 September 2008
 **/

#include <math.h>

#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include "SDL/SDL_opengl.h"

#include "class-assets.h"
#include "class-controller.h"
#include "class-timer.h"

	// Global Structs

	struct sPolarVector{

		float angle, velocity;
	};

	struct sJoypad{

		Sint16 leftX, leftY, rightX, rightY, triggers;
		Uint8  a, b, x, y, left, right, start, select, leftStick, rightStick;
		Uint8  hat;

		sPolarVector leftVector, rightVector;
	};

	struct sMouse{

		int  x, y, xRel, yRel;
		bool leftDown, middleDown, rightDown; 
		bool leftUp, middleUp, rightUp; 
		bool wheelUp, wheelDown;

		sPolarVector rightVector;
	};

	struct sKeyboard{

		bool a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

		sPolarVector leftVector;
	};

	class cEngine{

		public:

			// Public Member Fields

				// The internal game resolution (keep same aspect as below)
				static const int GAME_WIDTH  = 1024;	
				static const int GAME_HEIGHT = 768;

				// The actual screen resolution (keep same aspect as above)
				static const int SCREEN_WIDTH  = 1024;
				static const int SCREEN_HEIGHT = 768;
				static const int SCREEN_DEPTH  = 32;
				
				static const int STICK_DEADZONE	  = 40;		// Percentage to start reading the stick 
				static const int STICK_MAX_TRAVEL = 32500;	// The max radius of the stick vector velocity

				SDL_Event event;		// Handles Joypad, Keyboard and Mouse
				SDL_Surface	 *screen;	// Pointer to the Screen
				SDL_Joystick *stick;	// Pointer to the Joypad

			// Public Member Functions

				void getEvent();	

				void getJoypad   (sJoypad   &joypad);
				void getMouse    (sMouse    &mouse);
				void getKeyboard (sKeyboard &keyboard);

				void cls();		
				void refresh();	
				
				cEngine();
				~cEngine();

		private:

			// Public Member Fields

			float fTempNum;

			// Private Member Functions

			bool initSession();	// Initialises the SDL / OpenGL session			
	};
	
#endif // CLASS_ENGINE_H